package com.closer.server.biz.user.service.impl;

import com.closer.server.support.exception.ErrorCode;
import com.closer.server.support.exception.ThrowUtils;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.closer.server.biz.user.entity.UserStatistics;
import com.closer.server.mapper.user.UserStatisticsMapper;
import com.closer.server.biz.user.service.UserStatisticsService;
import org.springframework.stereotype.Service;

/**
 * 用户解题统计 服务层实现。
 *
 * @author closer
 */
@Service
public class UserStatisticsServiceImpl extends ServiceImpl<UserStatisticsMapper, UserStatistics>  implements UserStatisticsService{

    @Override
    public boolean saveStatistics(Long userId) {
        var statistics = UserStatistics.builder()
                .userId(userId)
                .build();
        var result = this.save(statistics);
        ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR,"用户角色保存失败");
        return result;
    }
}
